#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <vector>
using namespace std;

void practice1() {
    int n;
    cin >> n;
    vector<vector<int>> vv;
    for (int i = 0; i < n; i++) {
        vector<int> v(i + 1, 1);
        vv.push_back(v);
    }
    if (n > 2) {
        for (int i = 2; i < n; i++) {
            for (int j = 1; j < i; j++) {
                vv[i][j] = vv[i - 1][j] + vv[i - 1][j - 1];
            }
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < i + 1; j++) {
            printf("%5d", vv[i][j]);

        }
        cout << endl;
    }

}

void practice2() {
    int n, ret;
    cin >> n;

    int a = 0, b = 1, c = 1;
    vector<int> v({ 0,1 });
    while (c < n)
    {
        v.push_back(c);
        a = b;
        b = c;
        c = a + b;
    }
    v.push_back(c);

    int len = v.size();
    ret = (n - v[len - 2]) < (v[len - 1] - n) ? (n - v[len - 2]) : (v[len - 1] - n);

    cout << ret;

}
